#!/bin/sh

SVN_EXECUTABLE=svn

TEMP_DIR=`mktemp -q -d -t whp`

if [ $? -ne 0 ]; then
	echo "Cannot create temporary directory $TEMP_DIR"
	exit
fi

PACKAGE_ROOT=$TEMP_DIR/package
RESOURCE_ROOT=$TEMP_DIR/resources

# Creating package structure
mkdir -p $PACKAGE_ROOT/Library/WebServer/whp
mkdir -p $RESOURCE_ROOT

# Exporting the web honeypot project to package root
$SVN_EXECUTABLE export --quiet --force .. $PACKAGE_ROOT/Library/WebServer/whp

# Removing myself
rm -rf $PACKAGE_ROOT/Library/WebServer/whp/mac_package

# Copying read me text to package resources
cp ReadMe.rtf $RESOURCE_ROOT

# Creating the package
REVISION=`svn info .. | grep Revision | cut -f 2 -d ' '`
PACKAGE_NAME=webhoneypot-$REVISION.pkg
/Developer/usr/bin/packagemaker --root $PACKAGE_ROOT --id org.dshield.webhoneypot --resources $RESOURCE_ROOT --title "DShield Web Honeypot Project" --root-volume-only --out $PACKAGE_NAME

rm -rf $TEMP_DIR

